package service;

import dao.NoticeDao;
import donain.Notice;
import exception.NoticeException;

import java.sql.SQLException;
import java.util.List;

public class NoticeService {
    private NoticeDao dao = new NoticeDao();
    //后台系统，查询所有公告
    public List<Notice> getAllNotices() throws SQLException {

            return dao.getAllNotices();

    }
    //后台系统，添加公告
    public void addNotice(Notice notice) throws SQLException {

            dao.addNotice(notice);

    }
    //后台系统，根据id查找公告
    public Notice findNoticeById(String n_id) throws SQLException {

            return dao.findNoticeById(n_id);

    }

    //后台系统，根据id修改公告
    public void updateNotice(Notice bean) {
        try {
            dao.updateNotice(bean);
        } catch (SQLException e) {
//			throw new RuntimeException("根据id修改公告失败！");
            e.printStackTrace();
        }
    }

    //后台系统，根据id删除公告
    public void deleteNotice(String n_id) throws SQLException {

            dao.deleteNotice(n_id);

    }

    //前台系统，查询最新添加或修改的一条公告
    public Notice getRecentNotice() throws SQLException {

            return dao.getRecentNotice();

    }
}
